function WM_velocity(files,distance_between_sensors_WM,freq_aq_WM,tube_diameter,type,time)

    n = length(files);
    if n > 0           %If there are wire-mesh measurements
        fprintf('\n     Velocity analysis wire-mesh\n\n');
        
        if(strcmp(type,'VF'))
            str='void';    
        elseif(strcmp(type,'VF2'))
            str='void_midle_electrode';
        elseif(strcmp(type,'WL'))
            str='waterlevel';
        end
        
        for i=1:n
            fprintf('\n     Processing %s\n', files(i).name);
            filename=['.\Matlab_data\' files(i).name '_WM.mat'];
            if(strcmp(type,'VF'))
                filevariables = {'void_WM2', 'void_WM1'};            
            elseif(strcmp(type,'WL'))
                filevariables = {'waterlevel_WM2', 'waterlevel_WM1'};
            elseif(strcmp(type,'VF2'))
                filevariables = {'midle_electrode_void_WM1', 'midle_electrode_void_WM2'};
             end
             load(filename, filevariables{:});
            
            lvmfilename=[files(i).name '.lvm'];            
            [JL_aux JG_aux]=lvm(lvmfilename,time);           
            
            if(strcmp(type,'VF'))
                [matrix_velocity_WM(i,:), velocity_corr_bubble_nose] = velocity_analysis(void_WM1,void_WM2,freq_aq_WM,distance_between_sensors_WM,JL_aux,JG_aux,tube_diameter); %Calculates the velocity        
            elseif(strcmp(type,'WL'))
                [matrix_velocity_WM(i,:), velocity_corr_bubble_nose] = velocity_analysis(waterlevel_WM1,waterlevel_WM2,freq_aq_WM,distance_between_sensors_WM,JL_aux,JG_aux,tube_diameter); %Calculates the velocity        
            elseif(strcmp(type,'VF2'))
                [matrix_velocity_WM(i,:), velocity_corr_bubble_nose] = velocity_analysis(midle_electrode_void_WM1,midle_electrode_void_WM2,freq_aq_WM,distance_between_sensors_WM,JL_aux,JG_aux,tube_diameter); %Calculates the velocity        
            end
            
            if (exist('.\Results_velocity_analysis','dir') == 0)            %Creates Result directory if it does not exist yeat
                mkdir('Results_velocity_analysis');  
             end
             dir=['.\Results_velocity_analysis\' str];
             if (exist(dir,'dir') == 0)            %Creates Result directory if it does not exist yeat
                mkdir(dir);  
             end

            name_file = files(i).name;
%             name_file = [dir '\Velocity_nose_correlation_WM_' name_file];         
%             columnHeader = {'JL','JG','velocities nose with correlation(m/s)'};         
%             xlswrite(name_file, columnHeader,'Sheet1','A1');
%             xlswrite(name_file, velocity_corr_bubble_nose,'Sheet1','A2');      

            % \TODO ??
            savedir=[dir '\velocity_WM_' files(i).name '.mat'];
            save(savedir)           %Saves the workspace after velocity treatment                 
         
         
            name_figure_fig = [dir '\Figure_WM_velocity_' files(i).name '.fig'];
            name_figure_emf = [dir '\Figure_WM_velocity_' files(i).name '.tif'];
            saveas(gcf,name_figure_fig); 
            saveas(gcf,name_figure_emf);        
            
                      
        end    
        %end of the loop, plot all results!
        plotVelocityResult(matrix_velocity_WM,'WM',dir);
       

    end

  
  
  

    
    return

end